home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / math / nrpas13 / ddpoly.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1991-04-29  |  724 b   |  29 lines

  1. PROCEDURE ddpoly(c: glcarray; nc: integer; x: real;
  2.        VAR pd: glpdarray; nd: integer);
  3. (* Programs using routine DDPOLY must define the types
  4. TYPE
  5.    glcarray = ARRAY [1..nc] OF integer;
  6.    glpdarray = ARRAY [1..nd] OF integer;
  7. in the main routine. *)
  8. VAR
  9.    nnd,j,i: integer;
  10.    cnst: real;
  11. BEGIN
  12.    pd[1] := c[nc];
  13.    FOR j := 2 TO nd DO BEGIN
  14.       pd[j] := 0.0
  15.    END;
  16.    FOR i := nc-1 DOWNTO 1 DO BEGIN
  17.       IF (nd < (nc+1-i)) THEN nnd := nd ELSE nnd := nc+1-i;
  18.       FOR j := nnd DOWNTO 2 DO BEGIN
  19.          pd[j] := pd[j]*x+pd[j-1]
  20.       END;
  21.       pd[1] := pd[1]*x+c[i]
  22.    END;
  23.    cnst := 2.0;
  24.    FOR i := 3 TO nd DO BEGIN
  25.       pd[i] := cnst*pd[i];
  26.       cnst := cnst*i
  27.    END
  28. END;
  29.